<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户输入一个数字n，计算1+2+3+4+……n的和</title>
</head>
<body>
    <script>
        var n = prompt('inpunt a number'), sum = 0;
        for (var i = 1 ; i <= n ; i++) {
            sum += i
        }
        alert(sum)
    </script>
</body>
</html>